package yunplus.io.hchome.application;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import yunplus.io.hchome.display.activity.CrashLogActivity;

/**
 * Created by WangFan on 2016/12/28.
 */

public class AppExceptionHandler implements Thread.UncaughtExceptionHandler {

    //------------------ private const define ----------------------
    private static final String TAG = "AppExceptionHandler";

    private Context _mContext;

    public AppExceptionHandler(Context context) {
        this._mContext = context.getApplicationContext();
    }

    @Override
    public void uncaughtException(Thread thread, Throwable e) {
        Intent intent = new Intent(_mContext, CrashLogActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        Bundle bundle = new Bundle();
        bundle.putSerializable("e", e);
        intent.putExtras(bundle);
        _mContext.startActivity(intent);
//        System.exit(1);
    }
}
